Page({
  data: {
    active: 0,
    tabList: [
      {
        title: "待结账",
        component: "settled"
      },
      {
        title: "已结账",
        component: "closed"
      }
    ]
  },
  onLoad: function (options) {},

  onChange(e) {
    this.setData({
      active: e.detail.index
    });
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    const settled = this.selectComponent(".settled");
    const closed = this.selectComponent(".closed");
    if (settled) {
      settled.onPullDownRefresh && settled.onPullDownRefresh();
    } else if (closed) {
      closed.onPullDownRefresh && closed.onPullDownRefresh();
    } else {
      wx.stopPullDownRefresh();
    }
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    const settled = this.selectComponent(".settled");
    const closed = this.selectComponent(".closed");
    if (settled) {
      settled.onReachBottom && settled.onReachBottom();
    } else if (closed) {
      closed.onReachBottom && closed.onReachBottom();
    }
  }
});
